package cn.xo68.ide.plugin.common.swing.treetable;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public abstract class CheckContextProvider<T> implements Selector {

    private boolean checked;
    protected transient ChangeListener checkStateChangeListener;

    public CheckContextProvider(boolean checked, ChangeListener checkStateChangeListener) {
        this.checked = checked;
        this.checkStateChangeListener = checkStateChangeListener;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;

        checkStateChangeListener.stateChanged(new ChangeEvent(this));
    }

    @Override
    public void setSelect(boolean select) {
        this.setChecked(select);
    }

    public abstract T getContext();

    public abstract String getCheckText();

    public abstract Object getValueAt(int i);
}
